﻿
using System;
using System.Runtime.Serialization;
namespace SuperSocialShare.Error
{
    [DataContract]
    public class ErrorBase
    {
        public ErrorBase() 
        {
        }

        /// <summary>
        /// 根据提供的Exception实例初始化ErrorBase
        /// </summary>
        /// <param name="ex"></param>
        public ErrorBase(Exception ex) 
        {
            error_code = ex.HResult;
            error = ex.Message;
        }

        [DataMember]
        private int error_code { set; get; }

        [DataMember]
        private string error { set; get; }

        public virtual int ErrorCode
        {
            get
            {
                return error_code;
            }
        }

        /// <summary>
        /// 获取描述当前的错误的消息
        /// </summary>
        public virtual string Message
        {
            get
            {
                return error;
            }
        }
    }
}
